package com.geen.tuoke.ui.popupwindow

import android.content.Context
import android.view.View
import androidx.databinding.DataBindingUtil
import com.geen.tuoke.R
import com.geen.tuoke.databinding.PopupCustomerFuncBinding
import com.geen.tuoke.databinding.PopupTaskFuncBinding
import com.geen.tuoke.utils.ext.dp2px
import com.geen.tuoke.widget.popupwindow.EasyPopup
import com.qmuiteam.qmui.kotlin.onClick

/**
 * @author 文庆
 * @description 任务功能弹窗
 */
class TaskFuncPopup @JvmOverloads constructor(
    context: Context,
    var onTop: () -> Unit,
    var onMid: () -> Unit
) : EasyPopup(context) {

    var binding: PopupTaskFuncBinding? = null

    override fun onPopupWindowCreated() {
        super.onPopupWindowCreated()
        setContentView<EasyPopup>(R.layout.popup_task_func)

        setWidth<EasyPopup>(dp2px(100f))
            .setFocusAndOutsideEnable<EasyPopup>(true)
            .setHeight<EasyPopup>(dp2px(70f))
    }


    override fun onPopupWindowViewCreated(contentView: View) {
        super.onPopupWindowViewCreated(contentView)
        binding = DataBindingUtil.bind(contentView)

        binding?.run {

            ll1.onClick {
                dismiss()
                onTop()
            }
            ll2.onClick {
                dismiss()
                onMid()
            }

        }
    }
}